#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 100010, MOD = 5000011;
int s[N], f[N];
int n, k;
int main()
{
    cin >> n >> k;
    s[0] = f[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        f[i] = s[max(i - k - 1, 0)];
        s[i] = (s[i - 1] + f[i]) % MOD;
    }
    cout << s[n] << endl;
    return 0;
}